<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateApprovalLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('approval_logs', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('ID');
            $table->string('type')->comment('类型');
            $table->string('status')->default('pending')->comment('状态[:pending:待处理,,rprocessing:处理中,rectification:暂时处理,resolved:reject:驳回]');
            $table->text('reason')->nullable()->comment('原因');
            $table->string('operate_action')->comment('操作动作[1:创建,2:处理中,3:暂时处理,4:已处理,5:驳回]');
            $table->text('action_logs')->nullable()->comment('动作日志记录');
            $table->json('old')->nullable()->comment('老数据');
            $table->json('new')->nullable()->comment('新数据');
            $table->bigInteger('approval_id')->nullable()->comment('操作ID');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('修改时间');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            $table->bigInteger('created_admin_id')->default(0)->comment('创建人');
        });

        DB::statement('alter table'. ' ' .config('database.connections.mysql.prefix', '').'approval_logs comment "审批日志表"');

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('approval_logs');
    }
}
